home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Graphics Programming (2nd Edition)
/
Visual Basic Graphics Programming 2nd Edition.iso
/
OldSrc
/
CH1
/
SRC
/
AUTO.FRM
next >
Wrap
Text File
|
1996-05-02
|
3KB
|
115 lines
VERSION 4.00
Begin VB.Form AutoForm
Caption = "AutoRedraw and Paint Events"
ClientHeight = 4365
ClientLeft = 1140
ClientTop = 1800
ClientWidth = 7095
Height = 5055
Left = 1080
LinkTopic = "Form1"
ScaleHeight = 4365
ScaleWidth = 7095
Top = 1170
Width = 7215
Begin VB.PictureBox PaintPict
Height = 4095
Left = 3600
ScaleHeight = 269
ScaleMode = 3 'Pixel
ScaleWidth = 229
TabIndex = 1
Top = 240
Width = 3495
End
Begin VB.PictureBox AutoPict
AutoRedraw = -1 'True
Height = 4095
Left = 0
ScaleHeight = 269
ScaleMode = 3 'Pixel
ScaleWidth = 229
TabIndex = 0
Top = 240
Width = 3495
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "Paint Events"
Height = 255
Index = 1
Left = 3600
TabIndex = 3
Top = 0
Width = 3495
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "AutoRedraw"
Height = 255
Index = 0
Left = 0
TabIndex = 2
Top = 0
Width = 3495
End
Begin VB.Menu mnuFile
Caption = "&File"
Begin VB.Menu mnuFileExit
Caption = "E&xit"
End
End
End
Attribute VB_Name = "AutoForm"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Option Explicit
' ***********************************************
' Draw a grid skipping every other pixel.
' ***********************************************
Sub DrawPict(pic As PictureBox)
Const Amp = 3
Const PI = 3.14159
Const Per = 4 * PI
Dim i As Single
Dim j As Single
Dim hgt As Single
Dim wid As Single
pic.ScaleMode = 3 ' Pixel.
pic.Cls ' Clear the picture box.
For i = 0 To pic.ScaleHeight Step 4
pic.CurrentX = 0
pic.CurrentY = i
For j = 0 To pic.ScaleWidth
pic.Line -(j, i + Amp * Sin(j / Per))
Next j
Next i
For i = 1 To hgt Step 2
pic.Line (0, i)-(wid, i)
Next i
End Sub
Private Sub Form_Load()
DrawPict AutoPict
End Sub
Private Sub Form_Unload(Cancel As Integer)
End
End Sub
Private Sub mnuFileExit_Click()
Unload Me
End Sub
Private Sub PaintPict_Paint()
DrawPict PaintPict
End Sub